<?php
class Studio_m extends CI_Model{
	function __construct(){
		parent::__construct();
		$this->load->database();
	}
	
	//--get all studios--//
	function list_all_studios($per_page, $off_set){
		$query = 
				$this->db->select()
						 ->from("studio")
						 ->limit($per_page, $off_set)
						 ->get();
		if($query->num_rows()>=0){
			return $query;
		
		}else{
			return FALSE;
		}
		
	}
	
	//--count studios--//
	function count_studios(){
		$query = 
				$this->db->select()
						 ->from("studio")
						 ->get();
		$rowCount = $query->num_rows();
		if($rowCount >= 0){
			return $rowCount;
		}else{
			return 0;
		}
			
	}
	
	//--get studio by name--//
	function count_studio_by_name($studio_name){
		$query = 
			$this->db->select()
					 ->from("studio")
					 ->where("name", $studio_name)
					 ->get();
		$rowCount = $query->num_rows();
		if($rowCount >= 0){
			return $rowCount;
		}else{
			return 0;
		}
	}
	
	//--add studio--//
	function add_studio($data){
		$query = 
			$this->db->insert("studio", $data);
		return $query;	
	}
	
	//--get studio details--//
	function get_studio_details($studio_id){
		$query = 
			 	$this->db->select()
			 			 ->from("studio")
					     ->where("id", $studio_id)
					     ->limit(1)
					     ->get();
		if($query -> num_rows() >0){
			return $query->row();
		}else{
			return FALSE;
		}
	}

	//--edit studio details--//
	function edit_studio($studio_id, $data){
		$query = $this->db->update("studio", $data, array("id"=>$studio_id));
		return $query;
	}
	
	//--delete studio--//
	function delete_studio($id){
		$query = $this->db->delete('studio', array('id' => $id));
		if($query){
			return $query;
		} else{
			return FALSE;
		}
		
	}
	
	//--delete multi studios--//
	function delete_multi_studios($list) {
        $this->db->where('id in ' . $list);
        $query = $this->db->delete('studio');
        
        return $query;

    }
	
	
}